package com.hqyj.controller;


import com.hqyj.aop.PowerAnnotion;
import com.hqyj.excepiton.QuestionException;
import com.hqyj.interceptor.JwtToken;
import com.hqyj.pojo.Question;
import com.hqyj.service.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 * @since 2023-10-07
 */
@RestController
@RequestMapping("/question")
public class QuestionController {

    @Autowired
    IQuestionService iQuestionService;
    //新增
    @PostMapping("/question")
    @JwtToken
    @PowerAnnotion("admin")
    public HashMap<String,Object> add(@RequestBody Question question) throws QuestionException {
        return iQuestionService.add(question);
    }
    //删除
    @DeleteMapping("/question")
    @PowerAnnotion("simple")
    public HashMap<String,Object> del(Integer id) throws QuestionException {
        return iQuestionService.del(id);
    }
    //修改
    @PutMapping("/question")
    @PowerAnnotion("admin")
    public HashMap<String,Object> update(@RequestBody  Question question) throws QuestionException {
        return iQuestionService.update(question);
    }
    //动态分页查询
    @GetMapping("/question")
    @PowerAnnotion("leader")
    public HashMap<String,Object> queryByPage(Question question) throws QuestionException {
        return iQuestionService.queryByPage(question);
    }

}

